home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 024 / conquest / conq2.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  2KB  |  73 lines

  1. #include <stdio.h>
  2. #include "defs.h"
  3. #include "structs.h"
  4. #include "vars.h"
  5.  
  6. get_tf(tm, I0, starnum)
  7. tteam tm;
  8. int *I0;
  9. {
  10.         int i;
  11.         i=1;
  12.         while ( (tf[tm][i].dest!=0) && (i<27) ) i=i+1;
  13.         if ( i==27 )
  14.                 i=0;
  15.         else {
  16.                 tf[tm][i].s=0;
  17.                 tf[tm][i].t=0;
  18.                 tf[tm][i].c=0;
  19.                 tf[tm][i].b=0;
  20.                 tf[tm][i].eta=0;
  21.                 tf[tm][i].x = stars[starnum].x;
  22.                 tf[tm][i].y = stars[starnum].y;
  23.                 tf[tm][i].xf = tf[tm][i].x;
  24.                 tf[tm][i].yf = tf[tm][i].y;
  25.                 tf[tm][i].dest = starnum;
  26.                 tf[tm][i].origeta=0;
  27.                 tf[tm][i].blasting = false;
  28.         };
  29.         *I0 = i;
  30. }
  31.  
  32. joinsilent(team, parent, child)
  33. tteam team;
  34. struct sttf *parent, *child;
  35. {
  36.         parent->t = parent->t + child->t;
  37.         parent->s = parent->s + child->s;
  38.         parent->c = parent->c + child->c;
  39.         parent->b = parent->b + child->b;
  40.         if ( (parent->dest!=0) && (child->dest!=0) )
  41.                 tf_stars[parent->dest][team] --;
  42.         child->dest = 0;
  43. }
  44.  
  45. lose(Ship9s, L0se_none, typ, percent)
  46. int *Ship9s;
  47. char typ;
  48. float percent;
  49. boolean *L0se_none;
  50. {
  51.         int i,sleft;
  52.         int ships;
  53.         boolean lose_none;
  54.         ships = *Ship9s;
  55.         lose_none = *L0se_none;
  56.         if ( ships > 0 ) {
  57.                 sleft = ships;
  58.                 for ( i = 1 ; i<=ships; i++ ) {
  59.                         if ( ((float)(rand()&0x7fff)/(float)(0x7fff)) > percent ) {
  60.                                 lose_none = false;
  61.                                 sleft = sleft - 1;
  62.                         };
  63.                 };
  64.                 if ( sleft < ships ) {
  65.                         printf(" %2d%c", ships-sleft, typ);
  66.                         ships = sleft;
  67.                 };
  68.         };
  69.         *Ship9s = ships;
  70.         *L0se_none = lose_none;
  71. }
  72.  
  73.